home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-28 | 2.6 KB | 106 lines | [TEXT/MPS ] |
- /*
- WindowFrame.cp
-
- Implementation of WindowFrame class.
-
- by Patrick Beard.
-
- ©1990 by Patrick C. Beard. All rights reserved.
- */
-
- #ifndef __WINDOWFRAME__
- #include "WindowFrame.h"
- #endif
-
- #include <Events.h>
- #include <Script.h>
-
- static unsigned short GrowIconBits[] = {
- 0x0001, 0x0001, 0x0005, 0x0005,
- 0x0015, 0x0015, 0x0015, 0x0015,
- 0x0015, 0x0015, 0x0015, 0x0FF5,
- 0x0005, 0x3FFD, 0x0001, 0xFFFF,
- 0x0001, 0x0001, 0x0005, 0x0005,
- 0x0015, 0x0015, 0x0015, 0x0015,
- 0x0015, 0x0015, 0x0015, 0x0FF5,
- 0x0005, 0x3FFD, 0x0001, 0xFFFF
- };
-
- void WindowFrame::New(WindowPeek theWindow)
- {
- WindowDefinition::New(theWindow);
-
- Lock();
- itsBorderRgn = NewRgn();
- Unlock();
- }
-
- void WindowFrame::Dispose()
- {
- DisposeRgn(itsBorderRgn);
- }
-
- void WindowFrame::CalcRgns()
- {
- GrafPtr oldPort; GetPort(&oldPort);
- SetPort((GrafPtr)itsWindow);
- Rect portRect = itsWindow->port.portRect;
- LocalToGlobal(&topLeft(portRect));
- LocalToGlobal(&botRight(portRect));
- SetPort(oldPort);
- RectRgn(itsWindow->contRgn, &portRect);
- RectRgn(itsWindow->strucRgn, &portRect);
- short insetAmount = -(5 + GetWVariant((WindowPtr)itsWindow));
- InsetRgn(itsWindow->strucRgn, insetAmount, insetAmount);
- }
-
- void WindowFrame::DrawFrame()
- {
- if(!itsWindow->visible)
- return;
-
- // draw everything.
- FrameRgn(itsWindow->strucRgn);
- DiffRgn(itsWindow->strucRgn, itsWindow->contRgn, itsBorderRgn);
- FillRgn(itsBorderRgn, (itsWindow->hilited ? qd.black : qd.ltGray));
- if(itsWindow->hilited) {
- BitMap growIcon = { (Ptr)GrowIconBits, 2, {0, 0, 16, 16} };
- Rect growArea = (**itsWindow->strucRgn).rgnBBox;
- growArea.left = growArea.right - 16;
- growArea.top = growArea.bottom - 16;
- GrafPtr curPort; GetPort(&curPort);
- CopyBits(&growIcon, &curPort->portBits, &growIcon.bounds, &growArea, srcCopy, itsBorderRgn);
- }
- Rect frame = (**itsWindow->contRgn).rgnBBox;
- InsetRect(&frame, -1, -1);
- FrameRect(&frame);
- frame = (**itsWindow->strucRgn).rgnBBox;
- FrameRect(&frame);
- }
-
- void WindowFrame::DrawGrowImage(Rect& growRect)
- {
- Rect strucRect = growRect;
- short insetAmount = -(5 + GetWVariant((WindowPtr)itsWindow));
- InsetRect(&strucRect, insetAmount, insetAmount);
- FrameRect(&growRect);
- FrameRect(&strucRect);
- }
-
- long WindowFrame::Hit(Point& whereHit)
- {
- if(PtInRgn(whereHit, itsWindow->contRgn))
- return wInContent;
- DiffRgn(itsWindow->strucRgn, itsWindow->contRgn, itsBorderRgn);
- if(PtInRgn(whereHit, itsBorderRgn)) {
- Rect growArea = (**itsWindow->strucRgn).rgnBBox;
- growArea.left = growArea.right - 16;
- growArea.top = growArea.bottom - 16;
- if(PtInRect(whereHit, &growArea))
- return wInGrow;
-
- return wInDrag;
- }
- return wNoHit;
- }
-